// test2.ts

// 定义一个类来表示对象的结构
class ObjectWithId {
    id: i32;

    constructor(id: i32) {
        this.id = id;
    }
}

// 函数5：无参数传入传出，for循环1加到1000赋值数组object2，作为baseline
export function baselineTestObject(): void {
    let object2: Array<ObjectWithId> = new Array<ObjectWithId>(100000);
    for (let i = 0; i < 100000; i++) {
        object2[i] = new ObjectWithId(i + 1);
    }
}

// 函数6：无参数传入，for循环1到1000赋值给数组object2，传出数组object2
export function noInputWithOutputObject(): Array<ObjectWithId> {
    let object2: Array<ObjectWithId> = new Array<ObjectWithId>(100000);
    for (let i = 0; i < 100000; i++) {
        object2[i] = new ObjectWithId(i + 1);
    }
    return object2;
}

// 函数7：传入数组object1，for循环1到1000赋值给数组object2，这一步目的是控制变量，传出数组object2
export function withInputAndOutputObject(objects: Array<ObjectWithId>): Array<ObjectWithId> {
    let object2: Array<ObjectWithId> = new Array<ObjectWithId>(100000);
    for (let i = 0; i < 100000; i++) {
        object2[i] = new ObjectWithId(i + 1);
        //object2[i] = objects[i];
    }
    return object2;
}

// 函数8：传入数组object1，for循环1到1000赋值给数组object2，这一步目的是控制变量，无返回值
export function withInputNoOutputObject(objects: Array<ObjectWithId>): void {
    let object2: Array<ObjectWithId> = new Array<ObjectWithId>(100000);
    for (let i = 0; i < 100000; i++) {
        object2[i] = new ObjectWithId(i + 1);
        //object2[i] = objects[i];
        //console.log(`object2[3].id: ${object2[3].id}`);
        
    }
}